package com.ironman.compute.runner;

import com.ironman.compute.properties.SailingStandardProperties;
import com.ironman.compute.wrapper.SailingComputerWrapper;
import com.ironman.compute.wrapper.SailingParamWrapper;
import com.ironman.event.properties.SysTrainingProperties;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.mica.mqtt.core.client.MqttClient;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

/**
 * description 传感器runner
 * company 铁人科技
 *
 * @author 陈浩杰
 * @date 2023/12/15 9:48
 */
@Slf4j
@Component
@RequiredArgsConstructor
@ConditionalOnProperty(prefix = "sailing.compute", name = "enable", havingValue = "true")
public class ComputeRunner implements ApplicationRunner {

    final SysTrainingProperties sysTrainingProperties;

    final SailingStandardProperties sailingStandardProperties;

    final MqttClient mqttClient;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        SailingComputerWrapper sailingComputerWrapper = new SailingComputerWrapper(sysTrainingProperties, sailingStandardProperties, new SailingParamWrapper(), mqttClient);
        sailingComputerWrapper.doCompute();
    }

}
